package com.xinzhitong.www.controller;

import com.xinzhitong.www.exception.position.PositionNameIsNullException;
import com.xinzhitong.www.service.PositionService;
import com.xinzhitong.www.utils.Message;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 职位控制器
 *
 * @author 魏骆淳
 */
@CrossOrigin
@RestController
@RequestMapping("position")
public class PositionController {

    @Resource
    private PositionService positionService;

    /**
     * 获取职位名
     *
     * @return 职位名
     */
    @RequestMapping(value = "getPositionName", method = RequestMethod.GET)
    public Message positionName() {
        try {
            return Message.createSuc(positionService.getPositionName());
        } catch (PositionNameIsNullException e) {
            e.printStackTrace();
            return Message.createErr("职位名为空");
        }
    }

}
